<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'index.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
    <meta name="author" content="Muhammad Usman">
<%@include file="/commons/commonJs.jsp"%>
<script type="text/javascript">
var userType="${userType}";
var userName ="${user.userName }";
$(document).ready(function(){
      if(userType=="xz"){
      	ajaxDiv(false, '', '<%=basePath%>mgt/school/toSchoolSimple.do','' , showSchool2);
      }
	  
	  $("#userName").blur(function(){
	  	 myValidate('userName',true,'text',4,30);
	  });
	  $("#age").blur(function(){
	  	 myValidate('age',false,'num');
	  });
	  $("#mobile").blur(function(){
	  	 myValidate('mobile',false,'mobile');
	  });
	  $("#telNo").blur(function(){
	  	 myValidate('telNo',false,'tel');
	  });
	  $("#address").blur(function(){
	  	 myValidate('address',false,'text',4,50);
	  });
	  $("#onlineStartDate").blur(function(){
	  	 myValidate('onlineStartDate',true);
	  });
	  $("#onlineEndDate").blur(function(){
	  	 myValidate('onlineEndDate',true);
	  });
	  $("#offlineStartDate").blur(function(){
	  	 myValidate('offlineStartDate',true);
	  });
	  $("#offlineEndDate").blur(function(){
	  	 myValidate('offlineEndDate',true);
	  });
	  $("#schoolName").blur(function(){
	  	 myValidate('schoolName',false,'text',4,30);
	  });
	  $("#majorName").blur(function(){
	  	 myValidate('majorName',false,'text',4,30);
	  });
	  $("#chineseName").blur(function(){
	  	 myValidate('chineseName',false,'text',4,30);
	  });
	  $("#englishName").blur(function(){
	  	 myValidate('englishName',false,'text',2,30);
	  });
	  
	  
	  
	  $("#schoolId").val("${user.schoolId}");
	  
	  $('[data-rel="chosen"],[rel="chosen"]').chosen();
	  $("#studentLevel_chosen").css({"width":"100%"});
	  $("#schoolId_chosen").css({"width":"100%"});
	  $("#sex_chosen").css({"width":"100%"});
	  
});
function toSubmit(){
	if(userType=="xy"){
	  	 var flag1=myValidate('userName',true,'text',4,30);
	  	 var flag2=myValidate('age',false,'num');
	  	 var flag3=myValidate('mobile',false,'mobile');
	  	 var flag4=myValidate('address',false,'text',4,50);
	  	 var flag5=myValidate('onlineStartDate',true);
	  	 var flag6=myValidate('onlineEndDate',true);
	  	 var flag7=myValidate('offlineStartDate',true);
	  	 var flag8= myValidate('offlineEndDate',true);
	  	 var flag9= myValidate('schoolName',false,'text',4,30);
	  	 var flag10= myValidate('majorName',false,'text',4,30);
	  	 var flag11=myValidate('chineseName',false,'text',4,30);
	  	 var flag12=myValidate('englishName',false,'text',2,30);
	  	 var flag13=true;
	  	 if(userName!=null && userName!="" ){
	  	 	flag13=myValidateAjax('userName','<%=basePath%>mgt/user/checkUserName.do');
	  	 }
	  	 
	  	 var flag14=myValidate('telNo',false,'tel');
	  	 //alert(flag1+" : "+flag2+" : "+flag3+" : "+flag4+" : "+flag5+" : "+flag6+" : "+flag7+" : "+flag8+" : "+flag9+" : "+flag10+" : "+flag11+" : "+flag12+" : "+flag13+" : "+flag14);
		if(flag1&&flag2&&flag3&&flag4&&flag5&&flag6&&flag7&&flag8&&flag9&&flag10&&flag11&&flag12&&flag13&&flag14){
			formSubmit('formSubmit');
		}
	}else{
		var flag1=myValidate('userName',true,'text',4,30);
	  	 var flag2=myValidate('age',false,'num');
	  	 var flag3=myValidate('mobile',false,'mobile');
	  	 var flag4=myValidate('address',false,'text',4,50);
	  	 var flag11=myValidate('chineseName',false,'text',4,30);
	  	 var flag12=myValidate('englishName',false,'text',2,30);
	  	 var flag13=true;
	  	 if(userName!=null && userName!="" ){
	  	 	flag13=myValidateAjax('userName','<%=basePath%>mgt/user/checkUserName.do');
	  	 }
	  	 var flag14=myValidate('telNo',false,'tel');
	  	 if(flag1&&flag2&&flag3&&flag4&&flag11&&flag12&&flag13&&flag14){
			formSubmit('formSubmit');
		}
	}
}


function showSchool2(data,divId){
	$("#schoolId").html("");
	var schoolList = data["schoolList"];
	for ( var i = 0; i < schoolList.length; i++) {
		var school = schoolList[i];
		if(school!=null){
			$("#schoolId").append('<option value="'+school.id+'">'+school.schoolName+'</option>');
		}
	}
}
</script>
</head>

<body>

            <!-- content starts -->
                <div>
        <ul class="breadcrumb">
            <li>
                <a href="javascript:skipPage('<%=basePath%>mgt/login/content.do')">Home</a>
            </li>
            <li>
            	<c:if test="${userType=='xy' }"><a href="javascript:skipPage('<%=basePath%>mgt/user/userList.do','{userType:\'xy\'}')">学员管理</a></c:if>
		        <c:if test="${userType=='xz' }"><a href="javascript:skipPage('<%=basePath%>mgt/user/userList.do','{userType:\'xz\'}')">校长管理</a></c:if>
		        <c:if test="${userType=='jw' }"><a href="javascript:skipPage('<%=basePath%>mgt/user/userList.do','{userType:\'jw\'}')">教务管理</a></c:if>
		        <c:if test="${userType=='js' }"><a href="javascript:skipPage('<%=basePath%>mgt/user/userList.do','{userType:\'js\'}')">教师管理</a></c:if>
                
            </li>
            <li>
               <c:if test="${user!=null }">
              	<c:if test="${userType=='xy' }"><a href="#">更新学员信息</a></c:if>
		        <c:if test="${userType=='xz' }"><a href="#">更新校长信息</a></c:if>
		        <c:if test="${userType=='jw' }"><a href="#">更新教务信息</a></c:if>
		        <c:if test="${userType=='js' }"><a href="#">更新教师信息</a></c:if>
              </c:if>
              <c:if test="${user==null }">
              	<c:if test="${userType=='xy' }"><a href="#">新增学员信息</a></c:if>
		        <c:if test="${userType=='xz' }"><a href="#">新增校长信息</a></c:if>
		        <c:if test="${userType=='jw' }"><a href="#">新增教务信息</a></c:if>
		        <c:if test="${userType=='js' }"><a href="#">新增教师信息</a></c:if>
              </c:if>
            </li>
        </ul>
    </div>

<form id="formSubmit"  role="form" 
<c:if test="${user==null }"> action="${pageContext.request.contextPath }/mgt/user/userSave.do" </c:if> 
<c:if test="${user!=null }"> action="${pageContext.request.contextPath }/mgt/user/userUpdate.do" </c:if>
 method="POST">

<div class="row">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <c:if test="${user!=null }">
		              	<c:if test="${userType=='xy' }"><h2>更新学员信息</h2></c:if>
				        <c:if test="${userType=='xz' }"><h2>更新校长信息</h2></c:if>
				        <c:if test="${userType=='jw' }"><h2>更新教务信息</h2></c:if>
				        <c:if test="${userType=='js' }"><h2>更新教师信息</h2></c:if>
		              </c:if>
		              <c:if test="${user==null }">
		              	<c:if test="${userType=='xy' }"><h2>新增学员信息</h2></c:if>
				        <c:if test="${userType=='xz' }"><h2>新增校长信息</h2></c:if>
				        <c:if test="${userType=='jw' }"><h2>新增教务信息</h2></c:if>
				        <c:if test="${userType=='js' }"><h2>新增教师信息</h2></c:if>
		              </c:if>
                </div>
                <div class="box-content">
				 <fieldset>
				 	<input type="hidden" id="userType" name="userType" value="${userType }" >
                    <div class="form-group col-md-6">
	                    <label class="control-label" for="userName">用户名</label><span id="sp_userName" ></span>
	                    <input type="text" class="form-control" name="userName"  <c:if test="${user.userName!=null && user.userName!='' }">readonly="readonly"</c:if> value="${user.userName }" id="userName">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="age">年龄</label><span id="sp_age" ></span>
	                    <input type="text" class="form-control" name="age" value="${user.age }" id="age">
	                </div>
	                
	                <c:if test="${userType=='xy' }">
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="studentLevel">学员级别</label><span id="sp_studentLevel" ></span>
	                    <div class="controls">
	                        <select id="studentLevel" data-rel="chosen" name="studentLevel" class="form-control" value="${user.studentLevel }">
	                            <option <c:if test="${user.studentLevel==0 }">selected="selected"</c:if> value="0">level 0</option>
	                            <option <c:if test="${user.studentLevel==1 }">selected="selected"</c:if> value="1">level 1</option>
	                            <option <c:if test="${user.studentLevel==2 }">selected="selected"</c:if> value="2">level 2</option>
	                            <option <c:if test="${user.studentLevel==3 }">selected="selected"</c:if> value="3">level 3</option>
	                            <option <c:if test="${user.studentLevel==4 }">selected="selected"</c:if> value="4">level 4</option>
	                            <option <c:if test="${user.studentLevel==5 }">selected="selected"</c:if> value="5">level 5</option>
	                            <option <c:if test="${user.studentLevel==6 }">selected="selected"</c:if> value="6">level 6</option>
	                            <option <c:if test="${user.studentLevel==7 }">selected="selected"</c:if> value="7">level 7</option>
	                            <option <c:if test="${user.studentLevel==8 }">selected="selected"</c:if> value="8">level 8</option>
	                            <option <c:if test="${user.studentLevel==9 }">selected="selected"</c:if> value="9">level 9</option>
	                        </select>
	                    </div>
	                </div>
	                </c:if>
	                <c:if test="${userType=='xz' }">
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="schoolId">所属校区</label><span id="sp_schoolId" ></span>
	                    <div class="controls">
	                        <select id="schoolId" data-rel="chosen" name="schoolId" class="form-control">
	                            
	                        </select>
	                    </div>
	                </div>
	                </c:if>
	                
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="sex">性别</label><span id="sp_sex" ></span>
	                    <div class="controls">
	                        <select id="sex" data-rel="chosen" name="sex" class="form-control" >
	                            <option <c:if test="${user.sex=='女' }">selected="selected"</c:if> value="女">女</option>
	                            <option <c:if test="${user.sex=='男' }">selected="selected"</c:if> value="男">男</option>
	                        </select>
	                    </div>
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="chineseName">中文姓名</label><span id="sp_chineseName" ></span>
	                    <input type="text" class="form-control" name="chineseName" value="${user.chineseName }" id="chineseName">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="englishName">英文姓名</label><span id="sp_englishName" ></span>
	                    <input type="text" class="form-control" name="englishName" value="${user.englishName }" id="englishName">
	                </div>
	                
	                <c:if test="${userType=='xy' }">
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="offlineStartDate">线下课程开始时间</label><span id="sp_offlineStartDate" ></span>
	                    <input type="text" class="form-control" readonly="readonly" name="offlineStartDate" value="<fmt:formatDate value='${user.offlineStartDate }' pattern='yyyy-MM-dd' />" id="offlineStartDate" onclick="new WdatePicker({el:$dp.$('bftime'),dateFmt:'yyyy-MM-dd'})">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="offlineEndDate">线下课程结束时间</label><span id="sp_offlineEndDate" ></span>
	                    <input type="text" class="form-control" readonly="readonly" name="offlineEndDate" value="<fmt:formatDate value='${user.offlineEndDate }' pattern='yyyy-MM-dd' />" id="offlineEndDate" onclick="new WdatePicker({el:$dp.$('bftime'),dateFmt:'yyyy-MM-dd'})">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="onlineStartDate">线上课程开始时间</label><span id="sp_onlineStartDate" ></span>
	                    <input type="text" class="form-control" readonly="readonly" name="onlineStartDate" value="<fmt:formatDate value='${user.onlineStartDate }' pattern='yyyy-MM-dd' />" id="onlineStartDate" onclick="new WdatePicker({el:$dp.$('bftime'),dateFmt:'yyyy-MM-dd'})">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="onlineEndDate">线上课程结束时间</label><span id="sp_onlineEndDate" ></span>
	                    <input type="text" class="form-control" readonly="readonly" name="onlineEndDate" value="<fmt:formatDate value='${user.onlineEndDate }' pattern='yyyy-MM-dd' />" id="onlineEndDate" onclick="new WdatePicker({el:$dp.$('bftime'),dateFmt:'yyyy-MM-dd'})">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="schoolName">所在学校</label><span id="sp_schoolName" ></span>
	                    <input type="text" class="form-control" name="schoolName" value="${user.schoolName }" id="schoolName">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="majorName">所学专业</label><span id="sp_majorName" ></span>
	                    <input type="text" class="form-control" name="majorName" value="${user.majorName }" id="majorName">
	                </div>
	                </c:if>
	                
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="mobile">手机号码</label><span id="sp_mobile" ></span>
	                    <input type="text" class="form-control" name="mobile" value="${user.mobile }" id="mobile">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="telNo">手机号码</label><span id="sp_telNo" ></span>
	                    <input type="text" class="form-control" name="telNo" value="${user.telNo }" id="telNo">
	                </div>
	                <div class="form-group col-md-6">
	                    <label class="control-label" for="address">联系地址</label><span id="sp_address" ></span>
	                    <input type="text" class="form-control" name="address" value="${user.address }" id="address">
	                </div>
				  	
					
					
					
				  	<div class="form-group col-md-12">
						<button type="button" class="btn btn-primary" onclick="toSubmit();">保存</button>
						<button type="reset" class="btn">重置</button>
				  	</div>
				</fieldset>                    
                </div>
            </div>
        </div>
    </div><!--/span-->

</form>

    <!-- content ends -->


</body>
</html>
